<?php
/*
	Copyright 2006, 2007, 2008, 2009, 2010 Bastiaan Grutters
    
    This file is part of Ages of Strife website.

    Ages of Strife website is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Ages of Strife website is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Ages of Strife website.  If not, see <http://www.gnu.org/licenses/>.
 */
include( '../global/initialize.php' );

$query = "SELECT admin FROM users WHERE user_id = " . $_SESSION[ 'user_id' ];
$result = mysql_query( $query ) or die( "Query failed : " . mysql_error() );
$row = mysql_fetch_array($result, MYSQL_ASSOC);
if( isset( $row[ 'admin' ] ) && $row[ 'admin' ] == 1 ) {
?>
<html>
	<head>
		<title>
			Ages of Strife: Admin panel
		</title>
		<link type="text/css" rel="stylesheet" href="../global/agesofstrife.css" />
	</head>
	<body>
		<div id="root_container">
<?php
	include( "../global/ads.php" );
?>
			<div id="container">
				<div id="main-content">
<?php
	if( isset( $_SESSION[ 'debug_army_status' ] ) ) {
		print( 'Status: ' . $_SESSION[ 'debug_army_status' ] . '<br /><br />' );
		unset( $_SESSION[ 'debug_army_status' ] );
	}
?>
					<div class="blok">
						<strong>Create armies</strong><br />
						<form method="post" action="add_debug_army.php">
							Scouts: <input type="text" size="4" name="scouts" /><br />
							Infantry: <input type="text" size="4" name="infantry" /><br />
							Cavalry: <input type="text" size="4" name="cavalry" /><br />
							Artillery: <input type="text" size="4" name="artillery" /><br />
							Location:<br />
							(<input type="text" size="2" name="x" />, <input type="text" size="2" name="y" />)<br />
<?php
		$locations = get_locations();
		if( count( $locations ) > 0 ) {
?>								
								<?php transprint( 'or' ); ?><br />
								<?php transprint( 'to location' ); ?>: 
								<select name="location_id">
									<option value="-1"><?php transprint( 'None' ); ?></option>
<?php
			$printed = false;
			if( count( $locations ) > 0 ) {
				$printed = true;
				foreach( $locations AS $location ) {
?>
									<option value="<?php print( $location->location_id ); ?>"><?php print( get_location_title( $location ) ); ?></option>
<?php				
				}
			}
?>
								</select>
<?php
		}
?>								
							<br />
							For:<br />
							<input type="text" size="20" name="ruler1" /><br />
							<input type="text" size="20" name="ruler2" /><br />
							<input type="text" size="20" name="ruler3" /><br />
							<input type="submit" value="Add armies" />
						</form>
					</div>
					<br />
					<div class="blok">
						<a href="admin.php">Back</a>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
	<?php
}
else {
	$_SESSION[ 'admin' ] = 0;
	header( "Location: ../overview/overview.php" );
}
?>
